package com.example.demo.mapper;

import com.example.demo.pojo.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper
public interface RecruitInfoMapper {
    //查询全部部门数据
    @Select("select * from recruit_info")
    List<RecruitInfo> selectRecruitInfo();

    //保存数据
    @Insert("insert into recruit_info() values (#{title},#{salary},#{need},#{address},#{account},#{major},#{post})")
    void save(RecruitInfo recruitInfo);
    
    @Select("select * from recruit_info where account = #{account}")
    List<RecruitInfo> getByAccount(String account);

    //更新学生信息
    @Update("update recruit_info set title = #{title}, salary = #{salary} ,need = #{need},address = #{address}" +
            " ,account = #{account},major = #{major},post = #{post} where account = #{account}")
    void update(RecruitInfo recruitInfo);

    //邀请学生进入企业
    @Insert("insert into yaoqing(accountCm, accountStu,yaoqing) values (#{accountCm},#{accountStu},#{yaoqing})")
    void yaoQing(YaoQing yaoQing);

    //查找学生是否投递到了该企业 company_student 根据公司账号 返回学生账号
    @Select("select * from company_student where accountCm = #{accountCm}")
    List<Company_Student> getAccountByAccountCm(String accountCm);
    //企业同意学生 更新Company_student表信息
    @Update("update company_student set whether = #{whether} where accountCm = #{accountCm} and accountStu = #{accountStu}")
    void updateCompany_Student(Company_Student companyStudent);

    //审核通过
    @Update(("update recruit_info set post = 'true' where account = #{accountCm}"))
    void recruitUpdate(String accountCm);
}
